package com.example.demo.tencent;

import com.alibaba.fastjson.JSON;
import com.example.demo.vo.OrgCodeCertOcrResult;
import com.tencentcloudapi.common.Credential;
import com.tencentcloudapi.common.exception.TencentCloudSDKException;
import com.tencentcloudapi.common.profile.ClientProfile;
import com.tencentcloudapi.common.profile.HttpProfile;
import com.tencentcloudapi.ocr.v20181119.OcrClient;
import com.tencentcloudapi.ocr.v20181119.models.OrgCodeCertOCRRequest;
import com.tencentcloudapi.ocr.v20181119.models.OrgCodeCertOCRResponse;

;

public class OrgCodeCertOCR
{
    public static void main(String [] args) {
        try{

            Credential cred = new Credential("AKIDbXE8pIu6ATXLs6NBzYLtpXGKTO2wkcqq", "Jyb09dXNyMVQ6XwI9m9HBpGUXNyIOGtG");

            HttpProfile httpProfile = new HttpProfile();
            httpProfile.setEndpoint("ocr.tencentcloudapi.com");

            ClientProfile clientProfile = new ClientProfile();
            clientProfile.setHttpProfile(httpProfile);

            OcrClient client = new OcrClient(cred, "ap-beijing", clientProfile);

            OrgCodeCertOCRRequest req = new OrgCodeCertOCRRequest();
            req.setImageUrl("https://cwc.clouderwork.com/clouderworkorg/4b75142d8aab4774a7238940e8e51859.jpg");

            OrgCodeCertOCRResponse resp = client.OrgCodeCertOCR(req);

            System.out.println(OrgCodeCertOCRResponse.toJsonString(resp));

            OrgCodeCertOcrResult orgCodeCertOcrResult = new OrgCodeCertOcrResult();
            orgCodeCertOcrResult.setAddress(resp.getAddress());
            orgCodeCertOcrResult.setEntityName(resp.getName());
            orgCodeCertOcrResult.setOrgCode(resp.getOrgCode());
            orgCodeCertOcrResult.setValidDate(resp.getValidDate());

            System.out.println(JSON.toJSONString(orgCodeCertOcrResult));
        } catch (TencentCloudSDKException e) {
                System.out.println(e.toString());
        }

    }

}